-- 1. TABLE NAME and CONSTRAINT less than 64
    -- a. PRIMARY KEY
    -- b. UNIQUE
    -- c. CHECK
    -- d. FOREIGN
-- 2. TABLE NAME and CONSTRAINT greater than 64
    -- a. PRIMARY KEY
    -- b. UNIQUE
    -- c. CHECK
    -- d. FOREIGN

-- For each sub section
    --> CREATE TABLE --> NAMED CONSTRAINT --> TABLE CONSTRAINT
                                          --> COLUMN CONSTRAINT
                     --> UNNAMED CONSTRAINT --> TABLE CONSTRAINT
                                            --> COLUMN CONSTRAINT
    --> ALTER TABLE --> TABLE CONSTRAINT
                    --> COLUMN CONSTRAINT
    --> DROP ALL CONSTRAINTS

sp_babelfish_configure 'babelfishpg_tsql.escape_hatch_unique_constraint', 'ignore'
GO
--
--
/********** PRIMARY KEY (<64) **********/

-- named table constraint in create table
CREATE TABLE BABEL_2047_t1 (id INT, CONSTRAINT BABEL_2047_namedTableConstraint PRIMARY KEY(id))
GO
-- named column constraint in create table
CREATE TABLE BABEL_2047_t2 (id INT CONSTRAINT BABEL_2047_namedColumnConstraint PRIMARY KEY)
GO
-- un-named table constraint in create table
CREATE TABLE BABEL_2047_t3 (id INT, PRIMARY KEY(id))
GO
-- un-named column constraint in create table
CREATE TABLE BABEL_2047_t4 (id INT PRIMARY KEY)
GO
-- table constraint created using alter table
CREATE TABLE BABEL_2047_t5 (id INT)
GO
ALTER TABLE BABEL_2047_t5 ADD id1 INT PRIMARY KEY
GO
-- column constraint created using alter table
CREATE TABLE BABEL_2047_t6 (id INT)
GO
ALTER TABLE BABEL_2047_t6 ADD CONSTRAINT BABEL_2047_namedTableConstraint_alter_table PRIMARY KEY(id)
GO


-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

ALTER TABLE BABEL_2047_t1 DROP CONSTRAINT BABEL_2047_namedTableConstraint
GO
ALTER TABLE BABEL_2047_t2 DROP CONSTRAINT BABEL_2047_namedColumnConstraint
GO
ALTER TABLE BABEL_2047_t3 DROP CONSTRAINT babel_2047_t3_pkey
GO
ALTER TABLE BABEL_2047_t4 DROP CONSTRAINT babel_2047_t4_pkey
GO
ALTER TABLE BABEL_2047_t5 DROP CONSTRAINT babel_2047_t5_pkey
GO
ALTER TABLE BABEL_2047_t6 DROP CONSTRAINT BABEL_2047_namedTableConstraint_alter_table
GO

-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

DROP TABLE BABEL_2047_t1, BABEL_2047_t2, BABEL_2047_t3, BABEL_2047_t4, BABEL_2047_t5, BABEL_2047_t6
GO

/********** END OF PRIMARY KEY (<64) **********/
#
#
#
/********** UNIQUE (<64) **********/

-- named table constraint in create table
CREATE TABLE BABEL_2047_t1 (id INT, CONSTRAINT BABEL_2047_namedTableConstraint UNIQUE(id))
GO
-- named column constraint in create table
CREATE TABLE BABEL_2047_t2 (id INT CONSTRAINT BABEL_2047_namedColumnConstraint UNIQUE)
GO
-- un-named table constraint in create table
CREATE TABLE BABEL_2047_t3 (id INT, UNIQUE(id))
GO
-- un-named column constraint in create table
CREATE TABLE BABEL_2047_t4 (id INT UNIQUE)
GO
-- table constraint created using alter table
CREATE TABLE BABEL_2047_t5 (id INT)
GO
ALTER TABLE BABEL_2047_t5 ADD id1 INT UNIQUE
GO
-- column constraint created using alter table
CREATE TABLE BABEL_2047_t6 (id INT)
GO
ALTER TABLE BABEL_2047_t6 ADD CONSTRAINT BABEL_2047_namedTableConstraint_alter_table UNIQUE(id)
GO


-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

ALTER TABLE BABEL_2047_t1 DROP CONSTRAINT BABEL_2047_namedTableConstraint
GO
ALTER TABLE BABEL_2047_t2 DROP CONSTRAINT BABEL_2047_namedColumnConstraint
GO
ALTER TABLE BABEL_2047_t3 DROP CONSTRAINT babel_2047_t3_id_key
GO
ALTER TABLE BABEL_2047_t4 DROP CONSTRAINT babel_2047_t4_id_key
GO
ALTER TABLE BABEL_2047_t5 DROP CONSTRAINT babel_2047_t5_id1_key
GO
ALTER TABLE BABEL_2047_t6 DROP CONSTRAINT BABEL_2047_namedTableConstraint_alter_table
GO

-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

DROP TABLE BABEL_2047_t1, BABEL_2047_t2, BABEL_2047_t3, BABEL_2047_t4, BABEL_2047_t5, BABEL_2047_t6
GO

/********** END OF UNIQUE (<64) **********/
#
#
#
/********** CHECK (<64) **********/

-- named table constraint in create table
CREATE TABLE BABEL_2047_t1 (id INT, CONSTRAINT BABEL_2047_namedTableConstraint CHECK(id > 0))
GO
-- named column constraint in create table
CREATE TABLE BABEL_2047_t2 (id INT CONSTRAINT BABEL_2047_namedColumnConstraint CHECK(id > 0))
GO
-- un-named table constraint in create table
CREATE TABLE BABEL_2047_t3 (id INT, CHECK(id > 0))
GO
-- un-named column constraint in create table
CREATE TABLE BABEL_2047_t4 (id INT CHECK(id > 0))
GO
-- table constraint created using alter table
CREATE TABLE BABEL_2047_t5 (id INT)
GO
ALTER TABLE BABEL_2047_t5 ADD id1 INT CHECK(id > 0)
GO
-- column constraint created using alter table
CREATE TABLE BABEL_2047_t6 (id INT)
GO
ALTER TABLE BABEL_2047_t6 ADD CONSTRAINT BABEL_2047_namedTableConstraint_alter_table CHECK(id > 0)
GO


-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

ALTER TABLE BABEL_2047_t1 DROP CONSTRAINT BABEL_2047_namedTableConstraint
GO
ALTER TABLE BABEL_2047_t2 DROP CONSTRAINT BABEL_2047_namedColumnConstraint
GO
ALTER TABLE BABEL_2047_t3 DROP CONSTRAINT babel_2047_t3_id_check
GO
ALTER TABLE BABEL_2047_t4 DROP CONSTRAINT babel_2047_t4_id_check
GO
ALTER TABLE BABEL_2047_t5 DROP CONSTRAINT babel_2047_t5_id_check
GO
ALTER TABLE BABEL_2047_t6 DROP CONSTRAINT BABEL_2047_namedTableConstraint_alter_table
GO

-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

DROP TABLE BABEL_2047_t1, BABEL_2047_t2, BABEL_2047_t3, BABEL_2047_t4, BABEL_2047_t5, BABEL_2047_t6
GO

/********** END OF CHECK (<64) **********/
#
#
#
/********** FOREIGN KEY (<64) **********/

CREATE TABLE BABEL_2047_FOERIGN_TABLE (id INT UNIQUE)
GO

-- named table constraint in create table
CREATE TABLE BABEL_2047_t1 (id INT, CONSTRAINT BABEL_2047_namedTableConstraint FOREIGN KEY (id) REFERENCES BABEL_2047_FOERIGN_TABLE(id))
GO
-- named column constraint in create table
CREATE TABLE BABEL_2047_t2 (id INT CONSTRAINT BABEL_2047_namedColumnConstraint FOREIGN KEY (id) REFERENCES BABEL_2047_FOERIGN_TABLE(id))
GO
-- un-named table constraint in create table
CREATE TABLE BABEL_2047_t3 (id INT, FOREIGN KEY (id) REFERENCES BABEL_2047_FOERIGN_TABLE(id))
GO
-- un-named column constraint in create table
CREATE TABLE BABEL_2047_t4 (id INT FOREIGN KEY (id) REFERENCES BABEL_2047_FOERIGN_TABLE(id))
GO
-- table constraint created using alter table
CREATE TABLE BABEL_2047_t5 (id INT)
GO
ALTER TABLE BABEL_2047_t5 ADD id1 INT REFERENCES BABEL_2047_FOERIGN_TABLE(id)
GO
-- column constraint created using alter table
CREATE TABLE BABEL_2047_t6 (id INT)
GO
ALTER TABLE BABEL_2047_t6 ADD CONSTRAINT BABEL_2047_namedTableConstraint_alter_table FOREIGN KEY (id) REFERENCES BABEL_2047_FOERIGN_TABLE(id)
GO


-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

ALTER TABLE BABEL_2047_t1 DROP CONSTRAINT BABEL_2047_namedTableConstraint
GO
ALTER TABLE BABEL_2047_t2 DROP CONSTRAINT BABEL_2047_namedColumnConstraint
GO
ALTER TABLE BABEL_2047_t3 DROP CONSTRAINT BABEL_2047_t3_id_fkey
GO
ALTER TABLE BABEL_2047_t4 DROP CONSTRAINT BABEL_2047_t4_id_fkey
GO
ALTER TABLE BABEL_2047_t5 DROP CONSTRAINT BABEL_2047_t5_id1_fkey
GO
ALTER TABLE BABEL_2047_t6 DROP CONSTRAINT BABEL_2047_namedTableConstraint_alter_table
GO

-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

DROP TABLE BABEL_2047_t1, BABEL_2047_t2, BABEL_2047_t3, BABEL_2047_t4, BABEL_2047_t5, BABEL_2047_t6, BABEL_2047_FOERIGN_TABLE
GO

/********** END OF FOREIGN KEY (<64) **********/
#
#
#
#
#
/* RERUN ALL TESTS BUT WITH TABLENAME & CONSTRAINT NAME LENGTH GREATER THAN 64*/
#
/********** PRIMARY KEY (>=64) **********/

-- named table constraint in create table
CREATE TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT, CONSTRAINT BABEL_2047_namedTableConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL PRIMARY KEY(id))
GO
-- named column constraint in create table
CREATE TABLE BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT CONSTRAINT BABEL_2047_namedColumnConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL PRIMARY KEY)
GO
-- un-named table constraint in create table
CREATE TABLE BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT, PRIMARY KEY(id))
GO
-- un-named column constraint in create table
CREATE TABLE BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT PRIMARY KEY)
GO
-- table constraint created using alter table
CREATE TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT)
GO
ALTER TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL ADD id1 INT PRIMARY KEY
GO
-- column constraint created using alter table
CREATE TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL(id INT)
GO
ALTER TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL ADD CONSTRAINT BABEL_2047_namedTableConstraint_alter_table_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL PRIMARY KEY(id)
GO


-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

ALTER TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedTableConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO
ALTER TABLE BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedColumnConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO
ALTER TABLE BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t3_bbbbbbbbbaaaaaaaa9469c367a71f3fb0297b926f9a3_pkey
GO
ALTER TABLE BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t4_bbbbbbbbbaaaaaaaa58a9a6b9518e4a7ba04c4c2cfb3_pkey
GO
ALTER TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t5_bbbbbbbbbaaaaaaaa269e00d41fb4d6aec4e518e8701_pkey
GO
ALTER TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedTableConstraint_alter_table_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO

-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

DROP TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO

/********** END OF PRIMARY KEY (>=64) **********/
#
#
#
/********** UNIQUE (>=64) **********/

-- named table constraint in create table
CREATE TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT, CONSTRAINT BABEL_2047_namedTableConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL UNIQUE(id))
GO
-- named column constraint in create table
CREATE TABLE BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT CONSTRAINT BABEL_2047_namedColumnConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL UNIQUE)
GO
-- un-named table constraint in create table
CREATE TABLE BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT, UNIQUE(id))
GO
-- un-named column constraint in create table
CREATE TABLE BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT UNIQUE)
GO
-- table constraint created using alter table
CREATE TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT)
GO
ALTER TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL ADD id1 INT UNIQUE
GO
-- column constraint created using alter table
CREATE TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT)
GO
ALTER TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL ADD CONSTRAINT BABEL_2047_namedTableConstraint_alter_table_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL UNIQUE(id)
GO


-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

ALTER TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedTableConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO
ALTER TABLE BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedColumnConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO
ALTER TABLE BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t3_bbbbbbbbbaaaaaaaa9469c367a71f3fb0297b926f9_id_key
GO
ALTER TABLE BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t4_bbbbbbbbbaaaaaaaa58a9a6b9518e4a7ba04c4c2cf_id_key
GO
ALTER TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t5_bbbbbbbbbaaaaaaaa269e00d41fb4d6aec4e518e8_id1_key
GO
ALTER TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedTableConstraint_alter_table_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO

-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

DROP TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO

/********** END OF UNIQUE (>=64) **********/
#
#
#
/********** CHECK (>=64) **********/

-- named table constraint in create table
CREATE TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT, CONSTRAINT BABEL_2047_namedTableConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL CHECK(id > 0))
GO
-- named column constraint in create table
CREATE TABLE BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT CONSTRAINT BABEL_2047_namedColumnConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL CHECK(id > 0))
GO
-- un-named table constraint in create table
CREATE TABLE BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT, CHECK(id > 0))
GO
-- un-named column constraint in create table
CREATE TABLE BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT CHECK(id > 0))
GO
-- table constraint created using alter table
CREATE TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT)
GO
ALTER TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL ADD id1 INT CHECK(id > 0)
GO
-- column constraint created using alter table
CREATE TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT)
GO
ALTER TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL ADD CONSTRAINT BABEL_2047_namedTableConstraint_alter_table_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL CHECK(id > 0)
GO


-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

ALTER TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedTableConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO
ALTER TABLE BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedColumnConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO
ALTER TABLE BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t3_bbbbbbbbbaaaaaaaa9469c367a71f3fb0297b926_id_check
GO
ALTER TABLE BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t4_bbbbbbbbbaaaaaaaa58a9a6b9518e4a7ba04c4c2_id_check
GO
ALTER TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t5_bbbbbbbbbaaaaaaaa269e00d41fb4d6aec4e518e_id_check
GO
ALTER TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedTableConstraint_alter_table_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO

-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

DROP TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO

/********** END OF CHECK (>=64) **********/
#
#
#
/********** FOREIGN KEY (>=64) **********/

CREATE TABLE BABEL_2047_FOERIGN_TABLE (id INT UNIQUE)
GO

-- named table constraint in create table
CREATE TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT, CONSTRAINT BABEL_2047_namedTableConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL FOREIGN KEY (id) REFERENCES BABEL_2047_FOERIGN_TABLE(id))
GO
-- named column constraint in create table
CREATE TABLE BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT CONSTRAINT BABEL_2047_namedColumnConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL FOREIGN KEY (id) REFERENCES BABEL_2047_FOERIGN_TABLE(id))
GO
-- un-named table constraint in create table
CREATE TABLE BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT, FOREIGN KEY (id) REFERENCES BABEL_2047_FOERIGN_TABLE(id))
GO
-- un-named column constraint in create table
CREATE TABLE BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT FOREIGN KEY (id) REFERENCES BABEL_2047_FOERIGN_TABLE(id))
GO
-- table constraint created using alter table
CREATE TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT)
GO
ALTER TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL ADD id1 INT REFERENCES BABEL_2047_FOERIGN_TABLE(id)
GO
-- column constraint created using alter table
CREATE TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL (id INT)
GO
ALTER TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL ADD CONSTRAINT BABEL_2047_namedTableConstraint_alter_table_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL FOREIGN KEY (id) REFERENCES BABEL_2047_FOERIGN_TABLE(id)
GO


-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

ALTER TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedTableConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO
ALTER TABLE BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedColumnConstraint_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO
ALTER TABLE BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t3_bbbbbbbbbaaaaaaaa9469c367a71f3fb0297b926f_id_fkey
GO
ALTER TABLE BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t4_bbbbbbbbbaaaaaaaa58a9a6b9518e4a7ba04c4c2c_id_fkey
GO
ALTER TABLE BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_t5_bbbbbbbbbaaaaaaaa269e00d41fb4d6aec4e518e_id1_fkey
GO
ALTER TABLE BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL DROP CONSTRAINT BABEL_2047_namedTableConstraint_alter_table_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL
GO

-- look into pg_catalog and sys catalog for names
SELECT 
    CAST(c.relname AS VARCHAR(64)) AS tableName,
    CAST(i.conname AS VARCHAR(64)) AS constraintName
FROM pg_constraint i
    JOIN pg_class c ON (c.oid = i.conrelid)
WHERE
    c.relname like '%babel_2047%'
ORDER BY
    tableName ASC, constraintName ASC;
GO

DROP TABLE BABEL_2047_t1_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t2_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t3_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t4_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t5_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_t6_BBBBBBBBBAAAAAAAAABBBBBBBBEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLL, BABEL_2047_FOERIGN_TABLE
GO

/********** END OF FOREIGN KEY (>=64) **********/
